home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
The Utilities Experience
/
The Utilities Experience - Volume 1.iso
/
software
/
icons+tools
/
associate_v1.2
/
source
/
associategui.c
< prev
next >
Wrap
C/C++ Source or Header
|
1995-12-22
|
11KB
|
415 lines
/*
* Source machine generated by GadToolsBox V2.0b
* which is (c) Copyright 1991-1993 Jaba Development
*
* GUI Designed by : Hydra/LSD
*/
#include <exec/types.h>
#include <intuition/intuition.h>
#include <intuition/classes.h>
#include <intuition/classusr.h>
#include <intuition/imageclass.h>
#include <intuition/gadgetclass.h>
#include <libraries/gadtools.h>
#include <graphics/displayinfo.h>
#include <graphics/gfxbase.h>
#include <clib/exec_protos.h>
#include <clib/intuition_protos.h>
#include <clib/gadtools_protos.h>
#include <clib/graphics_protos.h>
#include <clib/utility_protos.h>
#include <string.h>
#include "AssociateGui.h"
struct Screen *Scr = NULL;
UBYTE *PubScreenName = "Workbench";
APTR VisualInfo = NULL;
struct Window *AssociateWnd = NULL;
struct Window *PickWnd = NULL;
struct Gadget *AssociateGList = NULL;
struct Gadget *PickGList = NULL;
struct Menu *AssociateMenus = NULL;
struct IntuiMessage AssociateMsg;
struct IntuiMessage PickMsg;
struct Gadget *AssociateGadgets[19];
struct Gadget *PickGadgets[3];
extern Class *initGet( void );
struct IClass *getClass = NULL;
struct _Object *getImage = NULL;
UWORD AssociateLeft = 13;
UWORD AssociateTop = 24;
UWORD AssociateWidth = 598;
UWORD AssociateHeight = 177;
UWORD PickLeft = 124;
UWORD PickTop = 17;
UWORD PickWidth = 195;
UWORD PickHeight = 187;
UBYTE *AssociateWdt = (UBYTE *)"Associate 1.2 (30/08/1995) By Dominic Clifton - Deluxe Software Ltd.";
UBYTE *PickWdt = (UBYTE *)"Pick A Type";
struct TextAttr topaz8 = {
( STRPTR )"topaz.font", 8, 0x00, 0x01 };
struct NewMenu AssociateNewMenu[] = {
NM_TITLE, (STRPTR)"Main", NULL, 0, NULL, NULL,
NM_ITEM, (STRPTR)"About", (STRPTR)"?", 0, 0L, (APTR)AssociateItem0,
NM_ITEM, (STRPTR)NM_BARLABEL, NULL, 0, 0L, NULL,
NM_ITEM, (STRPTR)"Quit!", (STRPTR)"q", 0, 0L, (APTR)AssociateItem1,
NM_END, NULL, NULL, 0, 0L, NULL };
UWORD AssociateGTypes[] = {
LISTVIEW_KIND,
LISTVIEW_KIND,
LISTVIEW_KIND,
GENERIC_KIND,
STRING_KIND,
BUTTON_KIND,
CHECKBOX_KIND,
BUTTON_KIND,
BUTTON_KIND,
BUTTON_KIND,
BUTTON_KIND,
BUTTON_KIND,
BUTTON_KIND,
BUTTON_KIND,
BUTTON_KIND,
BUTTON_KIND,
BUTTON_KIND,
BUTTON_KIND,
BUTTON_KIND
};
UWORD PickGTypes[] = {
LISTVIEW_KIND,
BUTTON_KIND,
BUTTON_KIND
};
struct NewGadget AssociateNGad[] = {
6, 17, 190, 88, (UBYTE *)"File Type", NULL, GD_TypeList, PLACETEXT_ABOVE, NULL, (APTR)TypeListClicked,
199, 17, 190, 88, (UBYTE *)"Name Patterns", NULL, GD_NamePList, PLACETEXT_ABOVE, NULL, (APTR)NamePListClicked,
392, 17, 190, 88, (UBYTE *)"File Patterns", NULL, GD_FilePList, PLACETEXT_ABOVE, NULL, (APTR)FilePListClicked,
6, 143, 20, 14, NULL, NULL, GD_IconPick, 0, NULL, (APTR)IconPickClicked,
28, 143, 253, 14, (UBYTE *)"Icon Filename", NULL, GD_IconStr, PLACETEXT_ABOVE, NULL, (APTR)IconStrClicked,
283, 143, 111, 14, (UBYTE *)"Icon Info", NULL, GD_IconInfo, PLACETEXT_IN, NULL, (APTR)IconInfoClicked,
269, 159, 26, 11, (UBYTE *)"Run Info When activated", NULL, GD_IconRun, PLACETEXT_LEFT, NULL, (APTR)IconRunClicked,
6, 107, 62, 14, (UBYTE *)"Add", NULL, GD_TypeAdd, PLACETEXT_IN, NULL, (APTR)TypeAddClicked,
70, 107, 62, 14, (UBYTE *)"Delete", NULL, GD_TypeDelete, PLACETEXT_IN, NULL, (APTR)TypeDeleteClicked,
199, 107, 62, 14, (UBYTE *)"Add", NULL, GD_NamePAdd, PLACETEXT_IN, NULL, (APTR)NamePAddClicked,
263, 107, 62, 14, (UBYTE *)"Delete", NULL, GD_NamePDelete, PLACETEXT_IN, NULL, (APTR)NamePDeleteClicked,
392, 107, 62, 14, (UBYTE *)"Add", NULL, GD_FilePAdd, PLACETEXT_IN, NULL, (APTR)FilePAddClicked,
456, 107, 62, 14, (UBYTE *)"Delete", NULL, GD_FilePDelete, PLACETEXT_IN, NULL, (APTR)FilePDeleteClicked,
403, 127, 185, 15, (UBYTE *)"Save", NULL, GD_Save, PLACETEXT_IN, NULL, (APTR)SaveClicked,
403, 143, 185, 15, (UBYTE *)"Help", NULL, GD_Help, PLACETEXT_IN, NULL, (APTR)HelpClicked,
403, 159, 185, 15, (UBYTE *)"OK", NULL, GD_OK, PLACETEXT_IN, NULL, (APTR)OKClicked,
134, 107, 62, 14, (UBYTE *)"Edit", NULL, GD_TypeEdit, PLACETEXT_IN, NULL, (APTR)TypeEditClicked,
327, 107, 62, 14, (UBYTE *)"Edit", NULL, GD_NamePEdit, PLACETEXT_IN, NULL, (APTR)NamePEditClicked,
520, 107, 62, 14, (UBYTE *)"Edit", NULL, GD_FilePEdit, PLACETEXT_IN, NULL, (APTR)FilePEditClicked
};
struct NewGadget PickNGad[] = {
2, 1, 184, 160, NULL, NULL, GD_PickType, 0, NULL, (APTR)PickTypeClicked,
2, 162, 91, 21, (UBYTE *)"Ok!", NULL, GD_PickOk, PLACETEXT_IN, NULL, (APTR)PickOkClicked,
95, 162, 91, 21, (UBYTE *)"Cancel", NULL, GD_PickCancel, PLACETEXT_IN, NULL, (APTR)PickCancelClicked
};
ULONG AssociateGTags[] = {
(GTLV_ShowSelected), NULL, (TAG_DONE),
(GTLV_ShowSelected), NULL, (TAG_DONE),
(GTLV_ShowSelected), NULL, (TAG_DONE),
(TAG_DONE),
(GTST_MaxChars), 256, (TAG_DONE),
(TAG_DONE),
(TAG_DONE),
(TAG_DONE),
(TAG_DONE),
(TAG_DONE),
(TAG_DONE),
(TAG_DONE),
(TAG_DONE),
(TAG_DONE),
(TAG_DONE),
(TAG_DONE),
(TAG_DONE),
(TAG_DONE),
(TAG_DONE)
};
ULONG PickGTags[] = {
(GTLV_ShowSelected), NULL, (TAG_DONE),
(TAG_DONE),
(TAG_DONE)
};
int SetupScreen( void )
{
if ( ! ( Scr = LockPubScreen( PubScreenName )))
return( 1L );
if ( ! ( VisualInfo = GetVisualInfo( Scr, TAG_DONE )))
return( 2L );
if ( ! ( getClass = initGet()))
return( 3L );
if ( ! ( getImage = NewObject( getClass, NULL, GT_VisualInfo, VisualInfo, TAG_DONE )))
return( 4L );
return( 0L );
}
void CloseDownScreen( void )
{
if ( getImage ) {
DisposeObject( getImage );
getImage = NULL;
}
if ( getClass ) {
FreeClass( getClass );
getClass = NULL;
}
if ( VisualInfo ) {
FreeVisualInfo( VisualInfo );
VisualInfo = NULL;
}
if ( Scr ) {
UnlockPubScreen( NULL, Scr );
Scr = NULL;
}
}
void AssociateRender( void )
{
UWORD offx, offy;
offx = AssociateWnd->BorderLeft;
offy = AssociateWnd->BorderTop;
DrawBevelBox( AssociateWnd->RPort, offx + 2, offy + 127, 398, 47, GT_VisualInfo, VisualInfo, TAG_DONE );
DrawBevelBox( AssociateWnd->RPort, offx + 2, offy + 1, 586, 124, GT_VisualInfo, VisualInfo, TAG_DONE );
}
int HandleAssociateIDCMP( void )
{
struct IntuiMessage *m;
struct MenuItem *n;
int (*func)();
BOOL running = TRUE;
while( m = GT_GetIMsg( AssociateWnd->UserPort )) {
CopyMem(( char * )m, ( char * )&AssociateMsg, (long)sizeof( struct IntuiMessage ));
GT_ReplyIMsg( m );
switch ( AssociateMsg.Class ) {
case IDCMP_REFRESHWINDOW:
GT_BeginRefresh( AssociateWnd );
AssociateRender();
GT_EndRefresh( AssociateWnd, TRUE );
break;
case IDCMP_CLOSEWINDOW:
running = AssociateCloseWindow();
break;
case IDCMP_GADGETUP:
case IDCMP_GADGETDOWN:
func = ( void * )(( struct Gadget * )AssociateMsg.IAddress )->UserData;
running = func();
break;
case IDCMP_MENUPICK:
while( AssociateMsg.Code != MENUNULL ) {
n = ItemAddress( AssociateMenus, AssociateMsg.Code );
func = (void *)(GTMENUITEM_USERDATA( n ));
running = func();
AssociateMsg.Code = n->NextSelect;
}
break;
}
}
return( running );
}
int OpenAssociateWindow( void )
{
struct NewGadget ng;
struct Gadget *g;
UWORD lc, tc;
UWORD offx = Scr->WBorLeft, offy = Scr->WBorTop + Scr->RastPort.TxHeight + 1;
if ( ! ( g = CreateContext( &AssociateGList )))
return( 1L );
for( lc = 0, tc = 0; lc < Associate_CNT; lc++ ) {
CopyMem((char * )&AssociateNGad[ lc ], (char * )&ng, (long)sizeof( struct NewGadget ));
ng.ng_VisualInfo = VisualInfo;
ng.ng_TextAttr = &topaz8;
ng.ng_LeftEdge += offx;
ng.ng_TopEdge += offy;
AssociateGadgets[ lc ] = g = CreateGadgetA((ULONG)AssociateGTypes[ lc ], g, &ng, ( struct TagItem * )&AssociateGTags[ tc ] );
if ( AssociateGTypes[ lc ] == GENERIC_KIND ) {
g->Flags |= GFLG_GADGIMAGE | GFLG_GADGHIMAGE;
g->Activation |= GACT_RELVERIFY;
g->GadgetRender = (APTR)getImage;
g->SelectRender = (APTR)getImage;
}
while( AssociateGTags[ tc ] ) tc += 2;
tc++;
if ( NOT g )
return( 2L );
}
if ( ! ( AssociateMenus = CreateMenus( AssociateNewMenu, GTMN_FrontPen, 0L, TAG_DONE )))
return( 3L );
LayoutMenus( AssociateMenus, VisualInfo, GTMN_TextAttr, &topaz8, TAG_DONE );
if ( ! ( AssociateWnd = OpenWindowTags( NULL,
WA_Left, AssociateLeft,
WA_Top, AssociateTop,
WA_Width, AssociateWidth,
WA_Height, AssociateHeight + offy,
WA_IDCMP, LISTVIEWIDCMP|IDCMP_GADGETUP|STRINGIDCMP|BUTTONIDCMP|CHECKBOXIDCMP|IDCMP_MENUPICK|IDCMP_CLOSEWINDOW|IDCMP_REFRESHWINDOW,
WA_Flags, WFLG_DRAGBAR|WFLG_DEPTHGADGET|WFLG_CLOSEGADGET|WFLG_SMART_REFRESH|WFLG_ACTIVATE,
WA_Gadgets, AssociateGList,
WA_Title, AssociateWdt,
TAG_DONE )))
return( 4L );
SetMenuStrip( AssociateWnd, AssociateMenus );
GT_RefreshWindow( AssociateWnd, NULL );
AssociateRender();
return( 0L );
}
void CloseAssociateWindow( void )
{
if ( AssociateMenus ) {
ClearMenuStrip( AssociateWnd );
FreeMenus( AssociateMenus );
AssociateMenus = NULL; }
if ( AssociateWnd ) {
CloseWindow( AssociateWnd );
AssociateWnd = NULL;
}
if ( AssociateGList ) {
FreeGadgets( AssociateGList );
AssociateGList = NULL;
}
}
int HandlePickIDCMP( void )
{
struct IntuiMessage *m;
int (*func)();
BOOL running = TRUE;
while( m = GT_GetIMsg( PickWnd->UserPort )) {
CopyMem(( char * )m, ( char * )&PickMsg, (long)sizeof( struct IntuiMessage ));
GT_ReplyIMsg( m );
switch ( PickMsg.Class ) {
case IDCMP_REFRESHWINDOW:
GT_BeginRefresh( PickWnd );
GT_EndRefresh( PickWnd, TRUE );
break;
case IDCMP_CLOSEWINDOW:
running = PickCloseWindow();
break;
case IDCMP_VANILLAKEY:
running = PickVanillaKey();
break;
case IDCMP_GADGETUP:
case IDCMP_GADGETDOWN:
func = ( void * )(( struct Gadget * )PickMsg.IAddress )->UserData;
running = func();
break;
}
}
return( running );
}
int OpenPickWindow( void )
{
struct NewGadget ng;
struct Gadget *g;
UWORD lc, tc;
UWORD offx = Scr->WBorLeft, offy = Scr->WBorTop + Scr->RastPort.TxHeight + 1;
if ( ! ( g = CreateContext( &PickGList )))
return( 1L );
for( lc = 0, tc = 0; lc < Pick_CNT; lc++ ) {
CopyMem((char * )&PickNGad[ lc ], (char * )&ng, (long)sizeof( struct NewGadget ));
ng.ng_VisualInfo = VisualInfo;
ng.ng_TextAttr = &topaz8;
ng.ng_LeftEdge += offx;
ng.ng_TopEdge += offy;
PickGadgets[ lc ] = g = CreateGadgetA((ULONG)PickGTypes[ lc ], g, &ng, ( struct TagItem * )&PickGTags[ tc ] );
while( PickGTags[ tc ] ) tc += 2;
tc++;
if ( NOT g )
return( 2L );
}
if ( ! ( PickWnd = OpenWindowTags( NULL,
WA_Left, PickLeft,
WA_Top, PickTop,
WA_Width, PickWidth,
WA_Height, PickHeight + offy,
WA_IDCMP, LISTVIEWIDCMP|BUTTONIDCMP|IDCMP_CLOSEWINDOW|IDCMP_VANILLAKEY|IDCMP_REFRESHWINDOW,
WA_Flags, WFLG_DRAGBAR|WFLG_DEPTHGADGET|WFLG_SMART_REFRESH|WFLG_ACTIVATE,
WA_Gadgets, PickGList,
WA_Title, PickWdt,
TAG_DONE )))
return( 4L );
GT_RefreshWindow( PickWnd, NULL );
return( 0L );
}
void ClosePickWindow( void )
{
if ( PickWnd ) {
CloseWindow( PickWnd );
PickWnd = NULL;
}
if ( PickGList ) {
FreeGadgets( PickGList );
PickGList = NULL;
}
}